<!DOCTYPE html>
<!-- This test cannot be upstreamed to WPT because it tests the behavior of
  V8 full code cache generation (PWAFullCodeCache) which is spesific to
  Chromium. -->
<title>Service Worker: invalid JS file should not cause SW install error</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.js"></script>
<body>
<script>
// Tests that storing an invalid JS file with syntax error into cache storage in
// service worker install event handler should not cause install error. There
// was a bug that the full code cache generation can't handle the error
// correctly, so that the service worker installation failed. See
// crbug.com/832202 for details.
promise_test(function(t) {
    const scope = 'resources/invalid-code-cache-scope/';
    const script = 'resources/invalid-code-cache-worker.js';

    return service_worker_unregister_and_register(t, script, scope)
      .then(reg => wait_for_state(t, reg.installing, 'activated'))
      .then(() => service_worker_unregister_and_done(t, scope));
  }, 'Invalid JS file in CacheStorage should not cause SW install error');
</script>
</body>
